var mapCity,geocoder;
var mapCity = new AMap.Map("container", {
	        resizeEnable: true,
			zoom: 18
	    }); 
	 mapCity.plugin('AMap.Geocoder', function() {
		 geocoder = new AMap.Geocoder({
		        radius: 1000,
		        extensions: "all"
		    });        
		});
function getAddressByLat(lnglatXY,callback){
	//console.log(geocoder)
	if (!geocoder){
		mapCity.plugin('AMap.Geocoder', function() {
			 geocoder = new AMap.Geocoder({
			        radius: 1000,
			        extensions: "all"
			    });        
			});
	}
	geocoder.getAddress(lnglatXY, function(status, result) {
        if (status === 'complete' && result.info === 'OK') {
           var address = result.regeocode.addressComponent.city||result.regeocode.addressComponent.province; //返回地址描述
           if(address.substring(address.length,address.length-1) == "市"){
        	   address = address.substring(0,address.length-1);
			}
           if (callback){
        	   callback(address);
           }
        }
    });        
}
